const path = require('path');

const webpack = require('webpack');

const htmlWebpackPlugins = require("html-webpack-plugin");

const VueLoaderPlugin = require('vue-loader/lib/plugin');

module.exports = {
  entry: path.join(__dirname,'./src/js/main.js'),
  output:{
    path:path.join(__dirname,'./dist'),
    filename: 'bundle.js'
  },
  plugins:[
    new VueLoaderPlugin(),
    new htmlWebpackPlugins({
      template: path.resolve(__dirname,'src/index.html'),
      filename: 'index.html'
    })
  ],
  module:{
    rules:[
      {test:/\.css$/,use:['style-loader','css-loader']},
      {test:/\.less$/,use:['style-loader','css-loader','less-loader']},
      {test:/\.scss$/,use:['style-loader','css-loader','sass-loader']},
      //防止两张同名图片发生冲突，加一个hash值
      {test: /\.(png|jpg|gif)$/, use: 'url-loader?limit=4371&name=[hash:8]-[name].[ext]' },
      { test: /\.js$/, use: 'babel-loader', exclude: /node_modules/ },
      { test: /\.(ttf|eot|svg|woff|woff2)$/, use: 'url-loader' },
      { test: /\.vue$/, use: 'vue-loader' },
      
    ]
  }
}
